package net.whg.controller;

import net.whg.service.AccountService;
import net.whg.util.JsonData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api/v1/account/")
public class AccountController {

    @Autowired
    private AccountService accountService;

    @GetMapping("init")
    public JsonData init() {
        accountService.initAccount();
        return JsonData.buildSuccess();
    }

    @GetMapping("list")
    public JsonData list() {
        return JsonData.buildSuccess(accountService.queryAccount());
    }

    @GetMapping("saveAll")
    public JsonData saveAll(){
        //accountService.saveAll();
        accountService.saveAllNew();
        return JsonData.buildSuccess();
    }

}
